import { redirect } from "react-router";
import { UpdateLocation } from "~/lib/server";
import type { Route } from "./+types/edit";

export async function clientAction({
    params,
    request,
}: Route.ActionArgs) {

    const formData = await request.formData();
    const updates = Object.fromEntries(formData);
    await UpdateLocation(+params.locationId, updates);
    return redirect(`/locations/${params.locationId}`);
}